package com.business.system.action;

import java.util.List;

import net.sf.json.JSONArray;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import com.business.base.action.BaseAction;
import com.business.system.pojo.TabRepairFlow;
import com.business.system.service.ITabRapairFlowService;

@Controller
@ParentPackage("struts-default")
@Namespace("/")
public class RepairFlowAction extends BaseAction {

	private static final long serialVersionUID = 1L;
	private TabRepairFlow repairFlow;
	@Autowired
	private ITabRapairFlowService repairFlowService;
	private String id;

	@Action(value = "RepairFlowAction_getCLDJ")
	public String getCLDJ() throws Exception {
		repairFlow = new TabRepairFlow();
		repairFlow.setId(id);

		List<TabRepairFlow> list = this.repairFlowService.findPreStep(
				repairFlow, "3");
		if (list.size() == 0) {
			String result = "{success:false}";
			this.jsonOut(result);
			return NONE;
		} else {
			JSONArray array = JSONArray.fromObject(list.get(0));
			String result = "{success:true,root:" + array.toString() + "}";
			this.jsonOut(result);
			return NONE;
		}
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}
}
